<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>springboot如何处理put及delete请求（restFUL）</title>
    <!--1. 引入jquery-->
    <!--<link rel="stylesheet" href="/webjars/jquery/3.6.4/jquery.min.js">-->
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <!--2. 引入bootstrap的样式-->
    <link rel="stylesheet" href="/webjars/bootstrap/3.4.1/css/bootstrap.min.css">
    <!--3. 引入bootstrap的js库-->
    <script src="/webjars/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
    <!--bs3 + (ctrl+j): 快捷键-->
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title">
                SpringBoot表单处理PUT 及 Delete请求
            </h3>
        </div>
        <div class="panel-body">
            <table class="table table-striped table-hover ">
                <!--1. post请求-->
                <tr>
                    <td>
                        <form action="/user/add" method="post" class="form-horizontal">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">用户名[POST]:</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" name="username" placeholder="输入用户名">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-10 col-sm-offset-2">
                                    <button type="submit" class="btn btn-primary btn-block">提交</button>
                                </div>
                            </div>
                        </form>
                    </td>
                </tr>
                <!--2. get请求-->
                <tr>
                    <td>
                        <form action="/user/findById" method="get" class="form-horizontal">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">用户名[GET]:</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" name="username" placeholder="输入用户名">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-10 col-sm-offset-2">
                                    <button type="submit" class="btn btn-primary btn-block">提交</button>
                                </div>
                            </div>
                        </form>
                    </td>
                </tr>
               <!--3. 表单发送put请求-->
                <tr>
                    <td>
                        <form action="/user/update" method="post" class="form-horizontal">
                            <input type="hidden" name="_m" value="put">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">用户名[PUT]:</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" name="username" placeholder="输入用户名">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-10 col-sm-offset-2">
                                    <button type="submit" class="btn btn-primary btn-block">提交</button>
                                </div>
                            </div>
                        </form>
                    </td>
                </tr>
                <!--4. 表单发送delete请求-->
                <tr>
                    <td>
                        <form action="/user/delete" method="post" class="form-horizontal">
                            <input type="hidden" name="_m" value="delete">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">用户名[DELETE]:</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" name="username" placeholder="输入用户名">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-10 col-sm-offset-2">
                                    <button type="submit" class="btn btn-primary btn-block">提交</button>
                                </div>
                            </div>
                        </form>
                    </td>
                </tr>
            </table>
        </div>
        <div class="panel-footer text-right">
            SpringBoot处理PUT.DELETE (2024)
        </div>
    </div>
</div>
</body>
</html>